/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package fait.ferm.ui.tables;

import fait.ferm.datafx.TableRow;
import fait.ferm.global.Glob;
import fait.ferm.persists.Cow;
import fait.ferm.persists.SimpleDirItem;
import java.text.SimpleDateFormat;
import java.util.Date;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;

/**
 *
 * @author alex
 */
public class FeedPersonalRow {
	@TableRow(orderNo=1, displayName="Корова")
	private final SimpleObjectProperty<Cow> cow;
	@TableRow(orderNo=2, displayName="Группе")
    private final BooleanProperty group;
	@TableRow(orderNo=3, displayName="Что")
	private final SimpleObjectProperty<SimpleDirItem> sup;
	@TableRow(orderNo=4, displayName="Кол-во")
	private final SimpleDoubleProperty quantity;
	@TableRow(orderNo=5, displayName="С")
	private final StringProperty begDate;
	@TableRow(orderNo=6, displayName="По")
	private final StringProperty endDate;

    public final BooleanProperty groupProperty() { return group; }
    public boolean isGroup() { return group.get(); }
    public void setGroup (boolean v) {group.set(v);    }


	public SimpleObjectProperty<Cow> cowProperty(){ return cow;}
	public Cow getCow() {return cow.get();}
	public void setCow(Cow p) {cow.set(p);}

	public SimpleObjectProperty<SimpleDirItem> supProperty(){return sup;}
	public SimpleDirItem getSup() {return sup.get();}
	public void setSup(SimpleDirItem p) {sup.set(p);}

	public SimpleDoubleProperty quantityProperty(){return quantity;}
	public Double getQuantity() {return quantity.get();}
	public void setQuantity(double p) {quantity.set(p);}

    public final StringProperty begDateProperty() { return begDate; }
    public String getBegDate() { return begDate.get(); }
    public void setBegDate(String newName) { begDate.set(newName); }
	
    public final StringProperty endDateProperty() { return endDate; }
    public String getEndDate() { return endDate.get(); }
    public void setEndDate(String newName) { endDate.set(newName); }

	public FeedPersonalRow(Cow cow, boolean isGroup, SimpleDirItem sup, double quantity, Date begDate, Date endDate) {
		this.cow = new SimpleObjectProperty<>( cow);
		this.group = new SimpleBooleanProperty( isGroup);
		
		this.sup = new SimpleObjectProperty<>(sup);
		this.quantity = new SimpleDoubleProperty(quantity);
		this.begDate = new SimpleStringProperty( Glob.dateFormat.format(begDate));
		this.endDate = new SimpleStringProperty(Glob.dateFormat.format(endDate));
	}
	
	@Override
	public String toString(){
		return cow.get().toString();
	}

	
}
	

